小编典典

无法构建 gem 本机扩展(mkmf(LoadError))-Ubuntu 12.04

all

我正在尝试在新的 ubuntu 机器上安装 rails。我安装了 ruby 和 rvm,但出现“无法构建 gem 本机扩展”错误。这是什么意思?

$ sudo gem install rails -v 3.2.9

(没有 sudo 表示我没有权限)

然后它会输出很多“获取”命令,最终会出现这个错误:

    Building native extensions.  This could take a while...
    ERROR:  Error installing rails:
        ERROR: Failed to build gem native extension.

            /usr/bin/ruby1.9.1 extconf.rb
    /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
        from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from extconf.rb:1:in `<main>'


    Gem files will remain installed in /var/lib/gems/1.9.1/gems/json-1.8.0 for inspection.
    Results logged to /var/lib/gems/1.9.1/gems/json-1.8.0/ext/json/ext/generator/gem_make.out

当我输入

$rails server

它说当前未安装rails


阅读 145

收藏
2022-07-06

共1个答案

小编典典

根据您的 ruby 版本,运行:

sudo apt-get install ruby1.9.1-dev
2022-07-06